package org.keeners.imageviewer {	
	
	/*
	settings, can be overridden with url args and/or flash vars
	*/
	
	public class Config{
		
		public var image_url:String = 'test.jpg';
		public var image_zoom_level_count:int = 0;
		public var image_zoom_ease:String = 'Quad';  // easeIn<Quad>/easeOut<Quad>, see tweener docs for others (Cubic, Linear, etc..)
		
		public var ocr:Object = {};
		public var ocr_url:String;
		public var ocr_data:String;
		public var ocr_query_url:String;
		public var ocr_query:String;
		public var ocr_search_algorithm:String = 'border_default';  // border_default, border_any, border_exact
		public var lang:String = 'en';
		
		public var instructions:Object = {
			'en': "move: click and drag or use arrow keys \nzoom in: shift/click or use mouse wheel \nzoom out: alt/click or use mouse wheel"
		};
		
		public function Config():void{
			
		}
		
		public function get_instructions():String{
			if (lang in instructions){
				return instructions[lang];
			}else{
				return instructions['en'];  
			}
		}
		
		public function get_ease():String{
			// allow lowercase argument --> "cubic" becomes "Cubic"
			return image_zoom_ease.charAt(0).toUpperCase() + image_zoom_ease.substr(1);
		}
		
		public function load_arguments(args:Object):void{
			/*
				get inputs into config
			*/
			
			var inputs:Array = ["image_url", "image_zoom_level_count", "image_zoom_ease", "ocr_url", "ocr_data", "ocr_query", "ocr_query_url", "ocr_search_algorithm", "lang"];
			
			for (var i=0;i<inputs.length;i++){
				
				var k = inputs[i];
				var v = this[k];
				
				if (k in args){
					v = isNaN(args[k]) ? args[k] : Number(args[k]);					
					/*
					// special cases here - not a string or number
					if (k.indexOf('_csv') >= 0){
						v = v.split(',');
					}
					*/
				}				
				trace (k+'='+v)
				this[k] = v;				
			}
		}
		
			   
	}
}
